package com.xiaotu.es.model;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * @author Mr.zhang
 * @Document: 将这个类的对象转换为 es 中一条文档进行录入
 * indexName:用来指定文档的索引名称
 * createIndex:用来指定是否创建索引
 * @module es-demo
 * @date 2022-05-27 16:44
 */
@Data
@Document(indexName = "products", createIndex = true)
public class Product {

    /**
     * @Id: 用来将放入对象 id 值 作为文档_id 进行映射
     */
    @Id
    private Integer id;

    @Field(type = FieldType.Keyword)
    private String title;

    @Field(type = FieldType.Double)
    private Double price;

    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String description;

}
